
package com.alibaba.nacos.common.http.client;

import com.alibaba.nacos.common.http.client.request.HttpClientRequest;
import com.alibaba.nacos.common.http.client.response.HttpClientResponse;
import com.alibaba.nacos.common.model.RequestHttpEntity;

import java.net.URI;

/**
 * desc:拦截客户端HTTP请求。可以实现该接口即可
 * Intercepts client-side HTTP requests. Implementations of this interface can be.
 *
 * @author mai.jh
 */
public interface HttpClientRequestInterceptor {

    /**
     * is intercept.
     *
     * @param uri               uri
     * @param httpMethod        http method
     * @param requestHttpEntity request entity
     * @return boolean
     */
    boolean isIntercept(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity);

    /**
     * desc:如果isIntercept方法是true，拦截给定的请求，并返回一个响应。否则，{@link HttpClientRequest}将用于执行
     *
     * if isIntercept method is true Intercept the given request, and return a response Otherwise,
     * the {@link HttpClientRequest} will be used for execution.
     *
     * @return HttpClientResponse
     */
    HttpClientResponse intercept();
}
